var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/imp/cpts/components/ShuttleTableHorizontal.tsx
var ShuttleTableHorizontal_exports = {};
__export(ShuttleTableHorizontal_exports, {
  default: () => ShuttleTableHorizontal_default
});
module.exports = __toCommonJS(ShuttleTableHorizontal_exports);
var import_react = require("react");
var import_functionalComponent = require("../../../../functionalComponent");
var import_util = require("../../../../util");
var import_query_panel = require("../../../query-panel");
var import_service = require("../../service");
var import_NoticeIconContent = __toESM(require("./NoticeIconContent"));
var import_ShuttleButtons = __toESM(require("./ShuttleButtons"));
var ShuttleTableHorizontal = (props) => {
  const { getRef, state, popupMode, flowCode, busData, rowDisable, iconVisible, defaultSelectedKeys } = props;
  const tableRequest = (0, import_react.useCallback)(
    async (defaultParams) => {
      const sourceId = state.sourceId;
      const newsourceId = (sourceId == null ? void 0 : sourceId.indexOf("_")) ? import_util.iup.split(sourceId, "_")[1] : sourceId;
      const result = await (0, import_service.loadSourceData)({ flowCode, busData, ...defaultParams, popupMode, sourceId: newsourceId });
      return result;
    },
    [state.sourceId]
  );
  const tableSelectedRequest = (0, import_react.useCallback)(async () => {
    if (!(defaultSelectedKeys == null ? void 0 : defaultSelectedKeys.length)) {
      return Promise.resolve({ total: 0, list: [] });
    }
    try {
      const sourceId = state.sourceId;
      const newsourceId = (sourceId == null ? void 0 : sourceId.indexOf("_")) ? import_util.iup.split(sourceId, "_")[1] : sourceId;
      const result = await (0, import_service.getSeletcedList)({
        id: newsourceId,
        tableIdStr: (defaultSelectedKeys || []).join(","),
        pageIndex: 1,
        pageSize: 1e3
      });
      return result;
    } catch {
    }
  }, [state.sourceId]);
  const onSearch = (_, queryCondition) => {
    var _a, _b;
    (_b = (_a = getRef("table")) == null ? void 0 : _a.current) == null ? void 0 : _b.getApi().setExtraParam({ queryCondition });
  };
  return /* @__PURE__ */ React.createElement(import_util.Layout, null, state.queryItems.length > 0 && /* @__PURE__ */ React.createElement(import_query_panel.QueryPanel, { items: state.queryItems, onSearch }), /* @__PURE__ */ React.createElement(import_util.Layout, { direction: "row", style: { flex: 1 } }, /* @__PURE__ */ React.createElement(
    import_functionalComponent.Panel,
    {
      title: "未选择",
      bodyStyle: { padding: 0, height: "100%" },
      style: { marginBottom: 0, width: "calc(50% - 23px)" }
    },
    /* @__PURE__ */ React.createElement(import_NoticeIconContent.default, { iconVisible }, /* @__PURE__ */ React.createElement(
      import_functionalComponent.Table,
      {
        showRowNumber: true,
        columns: state.columns,
        ref: getRef("tableMain"),
        autoLoad: true,
        request: tableRequest,
        key: state.sourceId,
        pagination: { hideOnSinglePage: false },
        rowSelection: {
          type: [import_functionalComponent.TableSelectionModel.MULTIPLE_INTERVAL, import_functionalComponent.TableSelectionModel.CHECKBOX],
          disabled: rowDisable
        }
      }
    ))
  ), /* @__PURE__ */ React.createElement(
    import_ShuttleButtons.default,
    {
      isHorizontal: false,
      rowDisable,
      subRowDisable: (xt) => defaultSelectedKeys.includes(xt.id),
      getRowKey: (x) => x.id,
      outRef: getRef("btnRef"),
      getActiveTable: () => {
        var _a, _b;
        return (_b = (_a = getRef("tableMain")) == null ? void 0 : _a.current) == null ? void 0 : _b.getApi();
      },
      getResultTable: () => {
        var _a, _b;
        return (_b = (_a = getRef("table")) == null ? void 0 : _a.current) == null ? void 0 : _b.getApi();
      }
    }
  ), /* @__PURE__ */ React.createElement(
    import_functionalComponent.Panel,
    {
      title: "已选择",
      bodyStyle: { padding: 0, height: "100%" },
      style: { marginBottom: 0, width: "calc(50% - 23px)" }
    },
    /* @__PURE__ */ React.createElement(
      import_functionalComponent.Table,
      {
        showRowNumber: true,
        columns: state.columns,
        ref: getRef("table"),
        request: tableSelectedRequest,
        key: state.sourceId,
        pagination: false,
        rowSelection: {
          type: [import_functionalComponent.TableSelectionModel.ROW],
          disabled: (xt) => defaultSelectedKeys.includes(xt.id)
        },
        onRow: (rowIndex, _, row) => ({
          onDoubleClick: () => {
            if (!defaultSelectedKeys.includes(row.id)) {
              getRef("btnRef").current.toLeft(rowIndex);
            }
          }
        })
      }
    )
  )));
};
var ShuttleTableHorizontal_default = (0, import_react.memo)(ShuttleTableHorizontal);
